package com.william.jdbcplus.test.config;

import com.william.jdbcplus.core.util.JdbcUtil;

import javax.sql.DataSource;

public class DBUtil {

    private final static DataSource mysql = initMysql();

    private final static DataSource oracle = initOracle();

    private final static DataSource sqlServer = initSqlserver();

    private static DataSource initMysql() {
        DataSource dataSource = JdbcUtil.createDataSource(ConfigUtil.mysql_url, ConfigUtil.mysql_username, ConfigUtil.mysql_password);
        return dataSource;
    }

    private static DataSource initOracle() {
        DataSource dataSource = JdbcUtil.createDataSource(ConfigUtil.oracle_url, ConfigUtil.oracle_username, ConfigUtil.oracle_password);
        return dataSource;
    }

    private static DataSource initSqlserver() {
        DataSource dataSource = JdbcUtil.createDataSource(ConfigUtil.sqlserver_url, ConfigUtil.sqlserver_username, ConfigUtil.sqlserver_password);
        return dataSource;
    }

    public static DataSource getMysql() {
        return mysql;
    }

    public static DataSource getOracle() {
        return oracle;
    }

    public static DataSource getSqlServer() {
        return sqlServer;
    }

}
